<?php	
$eMail = isset($_POST['eMail']) ? absolutelyEscapeString($_POST['eMail']) : '';
$password = isset($_POST['password']) ? absolutelyEscapeString($_POST['password']) : '';
$password2 = isset($_POST['password2']) ? absolutelyEscapeString($_POST['password2']) : '';
$firstName = isset($_POST['firstName']) ? absolutelyEscapeString($_POST['firstName']) : '';
$lastName = isset($_POST['lastName']) ? absolutelyEscapeString($_POST['lastName']) : '';
$city = isset($_POST['city']) ? absolutelyEscapeString($_POST['city']) : '';
$country = isset($_POST['country']) ? absolutelyEscapeString($_POST['country']) : '';
$birthYear = isset($_POST['birth_year']) ? absolutelyEscapeString($_POST['birth_year']) : '';
$birthMonth = isset($_POST['birth_month']) ? absolutelyEscapeString($_POST['birth_month']) : '';
$birthDay = isset($_POST['birth_day']) ? absolutelyEscapeString($_POST['birth_day']) : '';
$familyStatus = isset($_POST['familyStatus']) ? absolutelyEscapeString($_POST['familyStatus']) : '';
$userAgreement = isset($_POST['userAgreement']) ? true : false;
$keystring = isset($_POST['keystring']) ? absolutelyEscapeString($_POST['keystring']) : '';
$sessionKeystring = $objSession->__get('keystring');

$objRegist = new Authorization();
$objRegist->setEMAil($eMail);
$objRegist->setPass($password);
$objRegist->setPass2($password2);
$objRegist->setFirstName($firstName);
$objRegist->setLastName($lastName);
$objRegist->setCountry($country);
$objRegist->setCity($city);
$objRegist->setCountry($birthYear);
$objRegist->setCity($familyStatus);
$objRegist->setDate($birthYear, $birthMonth, $birthDay);
try{
  $errCaptcha = '';
  $errUserAgreement = '';  
  if(($sessionKeystring != '') && ($sessionKeystring ==  $keystring) && ($userAgreement)) {
    $objRegist->regist();
    $objSession->logIn($eMail, md5($password));
	  $objSession->saveSuccessMessage('Вы успешно зарегестрировались!');
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: ' . W_ABSPATH);
    exit();
  }
  else{
    if(($sessionKeystring == '') || ($sessionKeystring !=  $keystring))
      $errCaptcha = 'Вы неверно ввели защитный код<br />';
    if(!$userAgreement)
      $errUserAgreement = 'Мы регистрируем только тех, кто согласился с пользовательским соглашением<br />';
    $objRegist->checkRegist();  
    User_User::setUserMessage($errCaptcha, -1);
    
    
  }
}
catch(Exception_Multiline $exM) {
  $error = '';
  foreach ($exM as $eM) //Проходим по всем исключениям
    $error .= $eM . '<br />';  // Выводим отдельно взятое исключение
  $error .= $errCaptcha . $errUserAgreement;
  User_User::setUserMessage($error, -1);
}	
?>